package com.company.project.controller.ldjsc.sjyj;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.company.project.entity.ldjsc.sjrj.JscSjrjJryxztqkEntity;
import com.company.project.entity.ldjsc.sjyj.JscwzSjyjFaEntity;
import com.company.project.service.ldjsc.sjyj.JscwzSjyjFaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.company.project.common.utils.DataResult;




/**
 * 工作事务表
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2025-08-18 08:47:06
 */
@Controller
@RequestMapping("/sxzy")
public class JscwzSjyjFaController {
    @Autowired
    private JscwzSjyjFaService jscwzSjyjFaService;

    @ApiOperation(value = "方案")
    @GetMapping("/jsc-dd-zt/JscwzFa2")
    @ResponseBody
    public DataResult findListByPage(JscwzSjyjFaEntity jscwzSjyjFa){
        LambdaQueryWrapper<JscwzSjyjFaEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JscwzSjyjFaEntity::getType, jscwzSjyjFa.getType());
        queryWrapper.orderByDesc(JscwzSjyjFaEntity::getUpdate_time);

        if (jscwzSjyjFa.getMidgard_offset() != null){
            jscwzSjyjFa.setMidgard_page(1);
        }
        IPage<JscwzSjyjFaEntity> iPage = jscwzSjyjFaService.page(jscwzSjyjFa.getQueryPage(), queryWrapper);
        List<JscwzSjyjFaEntity> records = iPage.getRecords();


        // 构造所需的数据结构
        List<String> columnNames = Arrays.asList(
                "id",
                "type",
                "step",
                "sort",
                "status",
                "update_time"
        );

        Map<String, Object> result = new HashMap<>();
        result.put("columnNames", columnNames);
        result.put("value", records);

        return DataResult.success(result);
    }


}
